package com.inifitness.common.event.expression;

import org.jetbrains.annotations.NotNull;
import org.springframework.expression.ParserContext;

/**
 * 消息处理上下文
 *
 * @author sunjinfeng
 * @version 1.0
 * @since 2024/2/21 13:03
 */
public class MessageParserContext implements ParserContext {

  private final String expressionPrefix;

  private final String expressionSuffix;


  /**
   * 这里用阿里云短信${}替换掉#{} Create a new TemplateParserContext with the default "#{" prefix and "}"
   * suffix.
   */
  public MessageParserContext() {
    this("${", "}");
  }

  /**
   * Create a new TemplateParserContext for the given prefix and suffix.
   *
   * @param expressionPrefix the expression prefix to use
   * @param expressionSuffix the expression suffix to use
   */
  public MessageParserContext(String expressionPrefix, String expressionSuffix) {
    this.expressionPrefix = expressionPrefix;
    this.expressionSuffix = expressionSuffix;
  }


  @Override
  public final boolean isTemplate() {
    return true;
  }

  /**
   * 获取表达式前缀
   *
   * @return 表达式前缀
   */
  @NotNull
  @Override
  public final String getExpressionPrefix() {
    return this.expressionPrefix;
  }

  /**
   * 获取表达式后缀
   *
   * @return 表达式后缀
   */
  @NotNull
  @Override
  public final String getExpressionSuffix() {
    return this.expressionSuffix;
  }
}